#!/bin/bash
###############################################################
## to submit grid jobs, using prun (prun_makejob.sh)  ##
## usage: ./run.sh
## Lailin, June. 2012
###############################################################

# archive the source code
tarball='SelCode.tgz'
if [ -f ${tarball} ]; then
  rm ${tarball}
fi
cd SelCode
tar zcvf ${tarball} *
mv ${tarball} ../
cd ../

# submit grid jobs
#./prun_makejob.sh  Runlist/missed  > temp
#./prun_makejob.sh  Runlist/failed_run_v5  > temp
#./prun_makejob.sh  Runlist/test_root > temp
#./prun_makejob.sh  Runlist/list-data11-NTUP_SMWZ-p1035  > temp
./prun_makejob.sh  Runlist/mc11_ZH_NotOnDisk.list  > temp

# test if the submission failed
tag=`date +%y%m%d%H%M`
while read line;
do
  test_fail=`echo $line | grep fail`
  if [ "$test_fail" != "" ]; then
    echo $line >> failed_$tag
  fi
done < temp
